package com.mdb.open.trade.service.trade;


/*
* Copyright (C), 2017-2019 澳发科技(MDB)
* FileName: TfAmlLogService.java
* Author:   you.yichao
* Date:     2019-10-16
* History:
* <author>          <time>          <version>          <desc>
* you.yichao         2019-10-16          V1.00             代码生成器初始生成代码
* -----------------------------------------------------------
* 作者姓名           修改时间           版本号            描述
*/


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.mdb.bc.api.data.ResultEx;
import com.mdb.bc.database.mybatisplus.SuperService;
import com.mdb.open.trade.domain.po.trade.AmlLog;
import com.mdb.open.trade.mapper.trade.TfAmlLogMapper;
import org.springframework.stereotype.Service;

/**
 * 类描述：
 *  aml请求记录 服务类
 *
 * @author you.yichao
 * @date 2019-10-16
 */
@Service
public class TfAmlLogService extends SuperService<TfAmlLogMapper, AmlLog> {

    public ResultEx saveAmlLog(AmlLog amlLog) {
        int cnt = this.baseMapper.insert(amlLog);
        if (cnt != 1) {
            return ResultEx.fail();
        }
        return ResultEx.ok();
    }

    public ResultEx updateAmlLog(AmlLog amlLog) {

        AmlLog updateLog = new AmlLog();
        updateLog.setStatus(amlLog.getStatus());
        updateLog.setListNames(amlLog.getListNames());
        LambdaUpdateWrapper<AmlLog> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(AmlLog::getAmlSeqNo, amlLog.getAmlSeqNo());
        int cnt = this.baseMapper.update(updateLog, updateWrapper);
        if (cnt != 1) {
            return ResultEx.fail();
        }

        return ResultEx.ok();
    }


    public ResultEx<AmlLog> getBySeqNo(String seqNo) {
        return ResultEx.ok(this.baseMapper.selectOne(new LambdaQueryWrapper<AmlLog>()
                .eq(AmlLog::getAmlSeqNo, seqNo)));
    }

}
